
import sys
import time
import random
# from multiprocessing import Process
from window import Window
from graph2d import Button, BitMapImage

print('init')

BG_COLOR = (255, 255, 255, 255)

w = Window(1000, 500)
t = time.time()


def aaa():
    global t
    nt = time.time()
    if nt - t > 1:
        print('-------------------')
        b.visible = bool(1 - b.visible)
        if b.visible:
            w.title = 'visible'
        else:
            w.title = 'invisible'
        t = nt


def on_btn_click():
    print('->>>>>>>>------on_btn_click')

def on_btn3_click():
    print("==========click")

if __name__ == '__main__':
    b = Button('', 10, 10, 50, 50)
    b2 = Button('OK', 40, 40, 100, 30)
    b.visible = False
    w.addElement(b)
    w.addElement(b2)
    b.onClick(on_btn_click)
    b2.onClick(on_btn3_click)
    bitmap = BitMapImage(200, 100, '')
    w.addElement(bitmap)
    w.addAction(aaa)
    w.loop()
    w.quit()
